<template>
  <div class="avue-left-content">
    <img
      :src="infoVal.backgroundUrl ? infoVal.backgroundUrl : '/img/ZKRY.png'"
      style="width: 8%; height: 80%; margin: 0 20px 0 20px"
      alt=""
    />
    <span style="font-size: 20px; margin-right: 20px;white-space: nowrap;">{{
      infoVal.sysName || '临床研究数据管理与分析平台'
    }}</span>
    <div class="sleclt-title">
      <!-- <span style="margin-top: 5px">血液系统疾病临床医学研究</span>
      <CaretBottom style="width: 14px; height: 14px; margin-left: 4px" /> -->
      <el-dropdown>
        <div class="user-title" style="font-size: 12px; color: #fff;white-space: nowrap;">
          <span style="margin-top: 5px">{{ allListOfUserList[allListOfUserLength].name }}</span>
          <CaretBottom style="width: 14px; height: 14px" />
        </div>
        <template #dropdown>
          <!-- <div v-for="item in allListOfUserList" :key="item.id">
            {{ item.name }}
          </div> -->
          <el-dropdown-menu>
            <el-dropdown-item
              @click="toInfo(item, index)"
              v-for="(item, index) in allListOfUserList"
              :key="item.id"
            >
              {{ item.name}}
            </el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown>
    </div>
  </div>
</template>
<script setup name="leftMessage">
import { info } from '@/api/system/tenant';
import { allListOfUser } from '@/api/trial/trial';
import { onMounted, ref } from 'vue';
import { ElMessage, ElMessageBox } from 'element-plus';
import { useRouter } from 'vue-router';
const router = useRouter();
const crud = ref(null);
const store = useStore();
let infoVal = ref({});
const getTenant = () => {
  let domain = window.location.origin; //格式为http://192.168.1.119:2888
  info(domain).then(res => {
    const data = res.data;
    if (data.success && data.data.tenantId) {
      infoVal.value = data.data;
    }
  });
};
let allListOfUserList = ref([]);
let allListOfUserLength = ref(0);
const toInfo = (row, index) => {
  allListOfUserLength.value = index;
  router.replace({
    path: '/trial/menu',
    query: {
      selectTab: 1,
      trialId: row.id,
    },
    force: true
  });
};
onMounted(() => {
  getTenant();
  allListOfUser().then(res => {
    allListOfUserList.value = res.data.data;
  });
});
</script>
<style scoped lang="scss">
.avue-left-content {
  width: 46%;
  height: 100%;
  color: #fff;
  display: flex;
  align-items: center;
}
.sleclt-title {
  width: auto;
  height: 30px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: flex-end;
  flex: 1;
}
</style>
